#define DEBUG
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=100000, maxm=200000, mods=998244353;

class SegmentTree {
public:
  SegmentTree *left, *right;
  int l, r, v;

  SegmentTree(int l, int r) {
    this->l = l, this->r = r;
  }

  void merge(SegmentTree *o) {
    if (o) {
      if (l==r) {
	v = o->v || v;
      } else {
	if (!left) {
	  left = o->left;
	} else {
	  left->merge(o->left);
	}
	if (!right) {
	  right = o->right;
	} else {
	  right->merge(o->right);
	}
	v = 0;
	if (left) {
	  v += left->v;
	}
	if (right) {
	  v += right->v;
	}
      }
    }
  }

  void set(int t, int tv) {
    if (l==r) {
      v = tv;
    } else {
      int mid=(l+r)/2;
      v = 0;
      if (t<=mid) {
	if (!left) {
	  left = new SegmentTree(l, mid);
	}
	left->set(t, tv);
      } else {
	if (!right) {
	  right = new SegmentTree(mid+1, r);
	}
	right->set(t, tv);
      }
      if (left) {
	v += left->v;
      }
      if (right) {
	v += right->v;
      }
    }
  }

  int next() {
    if (!v) {
      return -1;
    } else if (l==r) {
      return l;
    } else {
      if (left && left->v) {
	return left->next();
      } else {
	return right->next();
      }
    }
  }
};

class Side {
public:
  int x, y;

  static bool cmp(Side a, Side b) {
    return a.x<b.x;
  }
};

int main() {
  freopen("graph.in", "r", stdin);
  freopen("graph.out", "w", stdout);

  static Side sides[maxm+1];
  int n, m;
  scanf("%d %d", &n, &m);

  for (int i=1; i<=m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    if (u<v) {
      sides[i].x = u;
      sides[i].y = v;
    } else {
      sides[i].x = v;
      sides[i].y = u;
    }
  }

  sort(sides+1, sides+m+1, Side::cmp);

  static SegmentTree *sgt[maxn+1];
  long long ans=1;
  for (int i=1; i<=n; i++) {
    sgt[i] = new SegmentTree(1, maxn);
  }
  for (int i=1, j=1; i<=n; i++) {
    sgt[i]->set(i, 0);
    for (; j<=m && sides[j].x==i; j++) {
      sgt[i]->set(sides[j].y, 1);
    }
    ans = (ans*(n-sgt[i]->v))%mods;
    int t=sgt[i]->next();
    if (t>0) {
      sgt[t]->merge(sgt[i]);
    }
  }
  printf("%lld", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
